-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix corruption of FITS tables with unsigned int columns on save and load #3680
Fix corruption of FITS tables with unsigned int columns on save and load #3680
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from the assignment to self.dq, this looks fine.
@@ -58,11 +58,6 @@ def __init__(self, ms, spec, exptime_key): | |||
self.surf_bright = np.zeros_like(self.flux) | |||
self.sb_error = np.zeros_like(self.flux) | |||
log.warning("There is no SURF_BRIGHT column in the input.") | |||
# xxx temporary self.dq = spec.spec_table.field("dq").copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only the "# xxx temporary " part of this line should be deleted. The actual assignment to self.dq needs to be done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! Oops, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(this has been fixed)
fits_rec = fits.FITS_rec(val) | ||
fits_rec._coldefs = coldefs | ||
# FITS_rec needs to know if it should be operating in pseudo-unsigned-ints mode, | ||
# otherwise it won't properly convert integer columns with TZEROn before saving. | ||
fits_rec._uint = uint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used in astropy.io.fits?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, here. The else... is where it was changing the dtype to float64.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Shall we go ahead and merge this? |
Addresses #3655
The problem on save turned out to be less of an astropy bug and more of a missing feature -- the public API doesn't currently allow us to put a FITS_rec into "pseudo unsigned integer" mode. We were already messing with astropy implementation details by setting
_colrefs
directly, so I don't think it's a big deal to also set_uint
.The problem on load is, I think, an astropy bug. I filed an issue and added a workaround here, which is to overwrite the incorrect FITS_rec dtype.